using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;

namespace ns20
{
	internal class Class186<T, U> : IDictionary<T, U>, ICollection<KeyValuePair<T, U>>, IEnumerable<KeyValuePair<T, U>>, IEnumerable, ICollection, IDictionary, Interface16
	{
		private struct Struct31<V, W> : IEnumerator, IDictionaryEnumerator
		{
			private readonly IEnumerator<KeyValuePair<V, W>> ienumerator_0;

			public DictionaryEntry Entry => (DictionaryEntry)Current;

			public object Key => Entry.Key;

			public object Value => Entry.Value;

			public object Current => new DictionaryEntry(ienumerator_0.Current.Key, ienumerator_0.Current.Value);

			public Struct31(IEnumerator<KeyValuePair<V, W>> e)
			{
				Class204.smethod_2(e, "e");
				ienumerator_0 = e;
			}

			public bool MoveNext()
			{
				return ienumerator_0.MoveNext();
			}

			public void Reset()
			{
				ienumerator_0.Reset();
			}
		}

		private readonly IDictionary idictionary_0;

		private readonly IDictionary<T, U> idictionary_1;

		private object object_0;

		[CompilerGenerated]
		private static Func<DictionaryEntry, KeyValuePair<T, U>> func_0;

		public ICollection<T> Keys
		{
			get
			{
				if (idictionary_0 != null)
				{
					return idictionary_0.Keys.Cast<T>().ToList();
				}
				return idictionary_1.Keys;
			}
		}

		public ICollection<U> Values
		{
			get
			{
				if (idictionary_0 != null)
				{
					return idictionary_0.Values.Cast<U>().ToList();
				}
				return idictionary_1.Values;
			}
		}

		public U this[T key]
		{
			get
			{
				if (idictionary_0 != null)
				{
					return (U)idictionary_0[key];
				}
				return idictionary_1[key];
			}
			set
			{
				if (idictionary_0 != null)
				{
					idictionary_0[key] = value;
				}
				else
				{
					idictionary_1[key] = value;
				}
			}
		}

		public int Count
		{
			get
			{
				if (idictionary_0 != null)
				{
					return idictionary_0.Count;
				}
				return idictionary_1.Count;
			}
		}

		public bool IsReadOnly
		{
			get
			{
				if (idictionary_0 != null)
				{
					return idictionary_0.IsReadOnly;
				}
				return idictionary_1.IsReadOnly;
			}
		}

		object IDictionary.this[object key]
		{
			get
			{
				if (idictionary_0 != null)
				{
					return idictionary_0[key];
				}
				return idictionary_1[(T)key];
			}
			set
			{
				if (idictionary_0 != null)
				{
					idictionary_0[key] = value;
				}
				else
				{
					idictionary_1[(T)key] = (U)value;
				}
			}
		}

		bool IDictionary.IsFixedSize
		{
			get
			{
				if (idictionary_1 != null)
				{
					return false;
				}
				return idictionary_0.IsFixedSize;
			}
		}

		ICollection IDictionary.Keys
		{
			get
			{
				if (idictionary_1 != null)
				{
					return idictionary_1.Keys.ToList();
				}
				return idictionary_0.Keys;
			}
		}

		ICollection IDictionary.Values
		{
			get
			{
				if (idictionary_1 != null)
				{
					return idictionary_1.Values.ToList();
				}
				return idictionary_0.Values;
			}
		}

		bool ICollection.IsSynchronized
		{
			get
			{
				if (idictionary_0 != null)
				{
					return idictionary_0.IsSynchronized;
				}
				return false;
			}
		}

		object ICollection.SyncRoot
		{
			get
			{
				if (object_0 == null)
				{
					Interlocked.CompareExchange(ref object_0, new object(), null);
				}
				return object_0;
			}
		}

		public object Object_0
		{
			get
			{
				if (idictionary_0 != null)
				{
					return idictionary_0;
				}
				return idictionary_1;
			}
		}

		public Class186(IDictionary dictionary)
		{
			Class204.smethod_2(dictionary, "dictionary");
			idictionary_0 = dictionary;
		}

		public Class186(IDictionary<T, U> dictionary)
		{
			Class204.smethod_2(dictionary, "dictionary");
			idictionary_1 = dictionary;
		}

		public void Add(T key, U value)
		{
			if (idictionary_0 != null)
			{
				idictionary_0.Add(key, value);
				return;
			}
			if (idictionary_1 == null)
			{
				throw new NotSupportedException();
			}
			idictionary_1.Add(key, value);
		}

		public bool ContainsKey(T key)
		{
			if (idictionary_0 != null)
			{
				return idictionary_0.Contains(key);
			}
			return idictionary_1.ContainsKey(key);
		}

		public bool Remove(T key)
		{
			if (idictionary_0 != null)
			{
				if (idictionary_0.Contains(key))
				{
					idictionary_0.Remove(key);
					return true;
				}
				return false;
			}
			return idictionary_1.Remove(key);
		}

		public bool TryGetValue(T key, out U value)
		{
			if (idictionary_0 != null)
			{
				if (!idictionary_0.Contains(key))
				{
					value = default(U);
					return false;
				}
				value = (U)idictionary_0[key];
				return true;
			}
			return idictionary_1.TryGetValue(key, out value);
		}

		public void Add(KeyValuePair<T, U> item)
		{
			if (idictionary_0 != null)
			{
				((IList)idictionary_0).Add(item);
			}
			else if (idictionary_1 != null)
			{
				idictionary_1.Add(item);
			}
		}

		public void Clear()
		{
			if (idictionary_0 != null)
			{
				idictionary_0.Clear();
			}
			else
			{
				idictionary_1.Clear();
			}
		}

		public bool Contains(KeyValuePair<T, U> item)
		{
			if (idictionary_0 != null)
			{
				return ((IList)idictionary_0).Contains(item);
			}
			return idictionary_1.Contains(item);
		}

		public void CopyTo(KeyValuePair<T, U>[] array, int arrayIndex)
		{
			if (idictionary_0 != null)
			{
				foreach (DictionaryEntry item in idictionary_0)
				{
					ref KeyValuePair<T, U> reference = ref array[arrayIndex++];
					reference = new KeyValuePair<T, U>((T)item.Key, (U)item.Value);
				}
			}
			else
			{
				idictionary_1.CopyTo(array, arrayIndex);
			}
		}

		public bool Remove(KeyValuePair<T, U> item)
		{
			if (idictionary_0 != null)
			{
				if (idictionary_0.Contains(item.Key))
				{
					object objA = idictionary_0[item.Key];
					if (object.Equals(objA, item.Value))
					{
						idictionary_0.Remove(item.Key);
						return true;
					}
					return false;
				}
				return true;
			}
			return idictionary_1.Remove(item);
		}

		public IEnumerator<KeyValuePair<T, U>> GetEnumerator()
		{
			if (idictionary_0 != null)
			{
				return (from DictionaryEntry dictionaryEntry_0 in idictionary_0
					select new KeyValuePair<T, U>((T)dictionaryEntry_0.Key, (U)dictionaryEntry_0.Value)).GetEnumerator();
			}
			return idictionary_1.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		void IDictionary.Add(object key, object value)
		{
			if (idictionary_0 != null)
			{
				idictionary_0.Add(key, value);
			}
			else
			{
				idictionary_1.Add((T)key, (U)value);
			}
		}

		IDictionaryEnumerator IDictionary.GetEnumerator()
		{
			if (idictionary_0 != null)
			{
				return idictionary_0.GetEnumerator();
			}
			return new Struct31<T, U>(idictionary_1.GetEnumerator());
		}

		bool IDictionary.Contains(object key)
		{
			if (idictionary_1 != null)
			{
				return idictionary_1.ContainsKey((T)key);
			}
			return idictionary_0.Contains(key);
		}

		public void Remove(object key)
		{
			if (idictionary_0 != null)
			{
				idictionary_0.Remove(key);
			}
			else
			{
				idictionary_1.Remove((T)key);
			}
		}

		void ICollection.CopyTo(Array array, int index)
		{
			if (idictionary_0 != null)
			{
				idictionary_0.CopyTo(array, index);
			}
			else
			{
				idictionary_1.CopyTo((KeyValuePair<T, U>[])array, index);
			}
		}

		[CompilerGenerated]
		private static KeyValuePair<T, U> smethod_0(DictionaryEntry dictionaryEntry_0)
		{
			return new KeyValuePair<T, U>((T)dictionaryEntry_0.Key, (U)dictionaryEntry_0.Value);
		}
	}
}
